package com.webSite.demo.cy.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.webSite.demo.cy.filter.MyFilter;
import com.webSite.demo.cy.listener.MyListener;
import com.webSite.demo.cy.servlet.MyServlet;

@Configuration
public class MyServerConfig {

	/**
	 * 注册servlet
	* @Title: servletRegistrationBean  
	* @param @return    参数  
	* @return ServletRegistrationBean    返回类型  
	* @throws
	 */
	@Bean
	public ServletRegistrationBean<MyServlet> servletRegistrationBean() {
		ServletRegistrationBean<MyServlet> registration = new ServletRegistrationBean<MyServlet>(new MyServlet());//new myServlet()
		registration.addUrlMappings("/myServlet");
        return registration;
	}
	
	/**
	 * 注册Filter
	* @Title: indexFilterRegistration  
	* @param @return    参数  
	* @return FilterRegistrationBean    返回类型  
	* @throws
	 */
	@Bean
    public FilterRegistrationBean<MyFilter> indexFilterRegistration() {
        FilterRegistrationBean<MyFilter> registration = new FilterRegistrationBean<MyFilter>(new MyFilter());//new myFilter()
        registration.addUrlPatterns("/myServlet");
        return registration;
    }
	
	/**
	 * 注册listener
	* @Title: servletListenerRegistrationBean  
	* @param @return    参数  
	* @return ServletListenerRegistrationBean    返回类型  
	* @throws
	 */
	@Bean
    public ServletListenerRegistrationBean<MyListener> servletListenerRegistrationBean(){
        ServletListenerRegistrationBean<MyListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<MyListener>(new MyListener());
        return servletListenerRegistrationBean;
    }
}
